    # coding:utf-8
from matplotlib import pyplot as plt
import random
import numpy
def fill_array_infect(iter_infected_number,infect,mobility):
    for i in  range(iter_infected_number):
        infect.append(round(random.random()*int(random.random()*mobility)))
    return numpy.sum(infect,axis=0);

if __name__ == '__main__':
    # 发病基数为 ：
    infected_cardinal = 2000
    #预测几小时的数据 
    forecast_time = 80
    # 12小时内流动率 （0-10）
    mobility = 5
    # 第几个小时 
    hour = [0,12]
    # 12h 后发现多少人发病
    infected_number = [1,3]
    # 每个人12小时内感染多少
    while(hour[len(hour)-1]<=forecast_time):
        infect = []
        # fill_array_infect(int(infected_number[len(infected_number)-1]),infect)
        temp = fill_array_infect(int(infected_number[len(infected_number)-1]),infect,mobility)
        hour.append(hour[len(hour)-1]+12)
        if(temp+int(infected_number[len(infected_number)-1])>=infected_cardinal):
            infected_number.append(infected_cardinal)
        else:
            infected_number.append(temp+int(infected_number[len(infected_number)-1]))
        # print(hour)
        # print(infected_number)
    # 标题
    plt.title("prevision of epidemic information")
    # 横坐标描述
    plt.xlabel('time')
    # 纵坐标描述
    plt.ylabel('number')
    plt.plot(hour,infected_number , label='number of infected persons', linewidth=2, color='red', marker='o', markerfacecolor='red', markersize=1)
    # 设置数字标签
    plt.legend(loc='upper left')
    plt.show()
    

    
        



